package red.uec.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import red.uec.model.RegisterMessageCodeRequest;
import red.uec.model.RegisterMessageCodeResponse;
import red.uec.model.RegisterRequest;
import red.uec.model.RegisterResponse;
import red.uec.service.UserService;

import javax.validation.Valid;

@RestController
@RequestMapping("/register")
@Slf4j
public class RegisterController {

    @Autowired
    private UserService userService;

    @PostMapping("/message_code")
    public RegisterMessageCodeResponse getMessageCode(@Valid RegisterMessageCodeRequest registerMessageCodeRequest){
        return userService.getMessageCode(registerMessageCodeRequest);
    }

    @PostMapping
    public RegisterResponse register(@Valid RegisterRequest registerRequest){
        return userService.register(registerRequest);
    }
}
